//@author A0105546J
package tasky.history;

import java.util.ArrayList;

import tasky.commons.Task;

public class CloneHistoryStatus {

	static public HistoryStatus execute(ArrayList<Task> list, String command) {

		ArrayList<Task> tasksClone = new ArrayList<Task>();

		copyListContent(list, tasksClone);

		return new HistoryStatus(tasksClone, command);

	}

	static private void copyListContent(ArrayList<Task> list,
			ArrayList<Task> clone) {

		Task singleTaskClone;

		for (int i = 0; i < list.size(); i++) {

			singleTaskClone = new Task();
			copySingleTask(list.get(i), singleTaskClone);
			clone.add(singleTaskClone);
		}

	}

	static private void copySingleTask(Task singleTask, Task singleTaskClone) {

		singleTaskClone.setId(singleTask.getId());
		singleTaskClone.setContent(singleTask.getContent());
		singleTaskClone.setDeadline(singleTask.getDeadline());
		singleTaskClone.setStart(singleTask.getStart());
		singleTaskClone.setEnd(singleTask.getEnd());
		singleTaskClone.setPriority(singleTask.isPriority());
		singleTaskClone.setLabel(singleTask.getLabel());
		singleTaskClone.setDone(singleTask.isDone());
		singleTaskClone.setUserInput(singleTask.getUserInput());

	}

}
